import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 1, 2, 3, 5, 2, 3, 2, 3, 7, 8, 7, 8, 2, 3, 2, 3};
        int n = arr.length, d = 0, count = 0, lmin = 0, lmax = 0, l = 0, min = 0, max = 0;
        int i;
        for (i = 1; i < n - 1; i++) {
            if (arr[i - 1] == arr[i + 1]) {
                count++;
                d += count == 1 ? i : 0;
            } else {
                if (d > 0)
                    count = i - d + 2;
                if (count >= max) {
                    min = max;
                    lmin = lmax;
                    max = count;
                    lmax = l;
                }
                count = 0;
                d = 0;
                l = i;
            }
        }
        if (d > 0)
            count = i - d + 2;
        if (count >= max) {
            min = max;
            lmin = lmax;
            max = count;
            lmax = l;
            if (min != max) {
                min = max;
                lmin = lmax;
            }
        }
        System.out.println(lmin + " " + min);
    }

    public static void task1() {
        Scanner scan = new Scanner(System.in);
        int n = 0, count = 0, a = 0, lmin = 0, lmax = 0, min = 0, max = 0, l = 0;
        System.out.println("Enter a:");
        a = scan.nextInt();
        System.out.println("Enter array length:");
        n = scan.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            System.out.println("Enter value for " + i + ":");
            arr[i] = scan.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            if (Math.abs(arr[i] - arr[i + 1]) <= a) {
                count++;
            } else {
                if (count >= max) {
                    min = max;
                    lmin = lmax;
                    lmax = l;
                    max = count;
                } else if (count > min) {
                    min = count;
                    lmin = l;
                }
                l = i;
                count = 0;
            }
        }
        System.out.println(String.format("index {0} count{1}", lmax, max));
    }
}